perm filename PROB7.PUB[LSP,JRA]3 blob sn#090227 filedate 1974-03-04 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	.SS(Problems involving %3prog%*)
C00005 ENDMK
C⊗;
.SS(Problems involving %3prog%*)
.BEGIN SELECT 1;INDENT 0,5;
.GROUP
I  Write %3prog%*-versions of the following functions (or predicates).

%21.%3 member[x;y]<= ... : x%1 is atomic; %3y%* is a list of atoms.  %3member%* is to 
return %3T%* just in the case that %3x%* is one of the elements in %3y%*.
.APART

%22.%1 The factorial function.

%23.%3  delete[x;y]<= ... : x%1 is atomic; %3y%* is a list of atoms.  %3delete%* is to 
return a list which looks like %3y%*, except all occurrences of %3x%*
have been deleted.

%24.%1 The %3append%* function.

%25.%3  last[x]<= ... : x%1 is a non-empty list.  %3last%* is to return the last 
element in %3x%*.

%26.%1  Now write the Sexpr translations of each of your functions.

II  Write BNF equations describing the syntax of %3prog%*.

III What is necessary to extend  the evaluator to recognize %3prog%* and friend.

IV  The %3go[cdr[...]]%*-construct on {yon(P25)} is better handled with a %2⊗→case 
statement↔←%*. A typical syntax for such might be:

←case<index>of <form%41%*>; ...<form%4n%*>.

<index> is to evaluate to an integer, i. Where  0<i≤n. The i%8th%* <form> of the
case-statement is executed, and is the value of the statement.
Construct a reasonable case statement and extend the evaluator to recognize
it.

V  This problem concerns ⊗→left-hand values↔←.  Some languages allow
constructs like:

.BEGIN TURN OFF "←";CENTER;
(%2if%* p(x) %2then%* x %2else%* y) ← exp, which is to mean the same as:

%2if%* p(x) %2then%* x← exp %2else%* y ← exp
.END
Can such a construct be written in LISP.  How natural is it?  How important
or useful is such a facility?

VI  Compare the %3prog%*-version of %3length%* on {yon(P45)} with 
%3length%41%1 on {yon(P19)}. Do you see any interesting relationships? 
Can you generalize?

.END